import { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import classNames from 'classnames'
import { toGoodsPage } from '@/utils/page_router'
import GoodsImg from '@/components/goods/goods-img/index'
import GoodsPrice from '@/components/goods/goods-price/index'
import './index.scss'

interface IProps {
  info: any
  className?: string
}

export default class GoodsOneItem extends Component<IProps, {}> {
  props: any
  render() {
    const { info={}, className } = this.props
    return (<View className={classNames('goods-one-item', className)} onClick={() => toGoodsPage(info)}>
      <View className='goods-img'>
        <GoodsImg info={info} lazyLoad/>
        {info.salesNumber && <View className='sold-num'>{info.salesNumber}件已售</View>}
      </View>
      <View className='goods-name'>
        <View className='name-text t-o-e-2'>{info.name}</View>
      </View>
      <GoodsPrice goods={info}/>
    </View>)
  }
}
